package cn.wyl;

import com.netflix.loadbalancer.RandomRule;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@MapperScan("cn.wyl.mapper")
public class BuyStart4010 {

    public static void main(String[] args) {
        SpringApplication.run(BuyStart4010.class,args);
    }

    @Bean //启动时获取一个机遇restful风格的客户端工具
    @LoadBalanced  //开启负载均衡
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

    //负载均衡算法
    @Bean
    public RandomRule randomRule(){
        return new RandomRule();
    }
}
